import ajax from './ajax';
import MockAjax from '../mock/mockAjax';

//统一管理项目接口的模块
export const reqGetCategoryListData = () => {
    return ajax.get('/api/product/getBaseCategoryList');
};

//获取banner轮播图接口
export const reqGetBannerListData = () => {
    return MockAjax.get('/banner');
};

//获取floor楼层接口
export const reqGetFloorListData = () => {
    return MockAjax.get('/floor');
};

//搜索参数获取搜索的商品数据
export const reqGetSearchGoodsInfoData = SearchParams => {
    return ajax.post('/api/list', SearchParams);
};

//获取详情页面的商品参数
export const reqGetDetailInfoData = id => {
    return ajax.get('/api/item/' + id);
};

//添加到商品购物车或更新购物车
export const reqGetCartData = (skuId, skuNum) => {
    return ajax.post(`/api/cart/addToCart/${skuId}/${skuNum}`);
};

// 发送请求获取购物车中的商品数据
export const reqGetShopCartListData = () => {
    return ajax.get('/api/cart/cartList');
};

// 设置购物车中商品的选中状态
export const reqGetChangeShopCartInfoList = (skuID, isChecked) => {
    return ajax.get(`/api/cart/checkCart/${skuID}/${isChecked}`);
};

//批量更新购物车
export const reqGetCheckCartListData = (isChecked, skuIdList) => {
    return ajax.post(`/api/cart/batchCheckCart/${isChecked}`, skuIdList);
};

//删除一条购物车数据
export const reqGetOneCartInfoListData = skuId => {
    return ajax.delete(`/api/cart/deleteCart/${skuId}`);
};

//删除批量选中的购物车
export const reqGetAllCartInfoListData = skuIdList => {
    return ajax.delete('/api/cart/batchDeleteCart', skuIdList);
};

//获取验证码
export const reqCode = phone => {
    return ajax.get(`/api/user/passport/sendCode/${phone}`);
};

//注册账号
export const reqUserRegister = user => {
    return ajax.post('/api/user/passport/register', user);
};

//登录
export const reqUserLogin = user => {
    return ajax.post('/api/user/passport/login', user);
};

//账号退出
export const reqUserOut = () => {
    return ajax.get('/api/user/passport/logout');
};

//送货地址
export const reqGetUserAddressListData = () => {
    return ajax.get('/api/user/userAddress/auth/findUserAddressList');
};

//获取订单交易页数据
export const reqGetTradeListData = () => {
    return ajax.get('/api/order/auth/trade');
};

//提交订单
export const reqGetSubmitOrder = (tradeNo, params) => {
    return ajax.post(`/api/order/auth/submitOrder?tradeNo=${tradeNo}`, params);
};

//获取订单支付信息
export const reqPayQrcode = orderId => {
    return ajax.get(`/api/payment/weixin/createNative/${orderId}`);
};

// 查询支付的订单状态  是否支付成功
export const reqQueryPayStatus = orderId =>
    ajax.get(`/api/payment/weixin/queryPayStatus/${orderId}`);
